<template>
    <div class="item_container">
        <label>
            <input class="completed" type="checkbox" 
                   @click="emit('completed', todoTask.taskId)" 
                   :checked="todoTask.isCompleted"/>
            <span class="todo_content">{{ todoTask.taskTitle }}</span>
        </label>
        <button class="delete" @click="emit('delete-item', todoTask.taskId)">删除</button>
    </div>
</template>

<script setup>

    const emit = defineEmits(["completed", "delete-item"])
    defineProps(["todoTask"])

</script>

<style scoped>
    .item_container {
        box-sizing: border-box;
        display: flex;
        flex-direction: row;
        align-items: center;
        width: 96%;
        padding: 5px 10px;
        margin-top: 10px;
        margin-bottom: 10px;
        justify-content: space-between;
        border-radius: 2px;
        border-color: black;
        border-width: 1px;
        border-style: solid;
    }
    .completed {
        width: 14px;
        height: 14px;
    }
    .todo_content {
        font-size: 18px;
        margin-left: 5px;
    }
    .delete {
        background-color: red;
        padding: 5px 10px;
        border-radius: 3px;
        border-color: red;
        color: white;
    }

</style>